/*
* @Author: Marte
* @Date:   2017-08-04 13:43:59
* @Last Modified by:   Marte
* @Last Modified time: 2017-09-22 14:52:05
*/


        //显示提示框，目前三个参数(txt：要显示的文本；time：自动关闭的时间（不设置的话默认1500毫秒）；status：默认0为错误提示，1为正确提示；)
         function showTips(txt,time,status)
        {
            var htmlCon = '';
            if(txt != ''){
                if(status != 0 && status != undefined){
                    htmlCon = '<div class="tipsBox" style="width:220px;padding:10px;background-color:#4AAF33;border-radius:4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;color:#fff;box-shadow:0 0 3px #ddd inset;-webkit-box-shadow: 0 0 3px #ddd inset;text-align:center;position:fixed;top:100px;left:50%;z-index:999999;margin-left:-120px;"><img src="images/ok.png" style="vertical-align: middle;margin-right:5px;" alt="OK，"/>'+txt+'</div>';
                }else{
                    htmlCon = '<div class="tipsBox" style="width:220px;padding:10px;background-color:#D84C31;border-radius:4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;color:#fff;box-shadow:0 0 3px #ddd inset;-webkit-box-shadow: 0 0 3px #ddd inset;text-align:center;position:fixed;top:25%;left:50%;z-index:999999;margin-left:-120px;"><img src="images/err.png" style="vertical-align: middle;margin-right:5px;" alt="Error，"/>'+txt+'</div>';
                }
                $('body').prepend(htmlCon);
                if(time == '' || time == undefined){
                    time = 1500;
                }
                setTimeout(function(){ $('.tipsBox').remove(); },time);
            }
        }

window.onload=function()
{
    var userReg = /^[A-Za-z0-9]+$/; //用户名正则
    var fm=document.forms['fm'];
    fm.email.onfocus=function()
    {
        var username=fm.username.value;
        alert(username);
        if(username.length<=0)
        {
            showTips('请填写您的用户名~');
        }else if(!userReg.test(username))
        {
           showTips('您的用户名格式不正确~');
        }
    }
    var emailReg= /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; //邮件正则
    fm.password.onfocus=function()
    {
        var email=fm.email.value;
        if(email.length<=0)
        {
            showTips('请填写您的常用邮箱~');
        }else if(!emailReg.test(email))
        {
            showTips('您的邮箱格式错咯~');
        }
    }

    fm.prepassword.onfocus=function()
    {
        var password=fm.password.value;
        if(password.length<=0)
        {
            showTips('请填写您的密码~');
        }else if(password.length<=6||password.length>=16)
        {
            showTips('您的密码不能少于6位或者多于16位哦~');
        }
    }

    fm.yzm.onfocus=function()
    {
         var password=fm.password.value;
        var prepassword=fm.prepassword.value;
        if(prepassword.length<=0)
        {
            showTips('请再次输入您的密码~');
        }else if(prepassword!=password)
        {
            showTips('您输入的两次密码不一致哦~');
        }
    }

 function gonext()
            {
                 $('.processorBox li').click(function(){
                var i = $(this).index();
                $('.processorBox li').removeClass('current').eq(i).addClass('current');
                $('.step').fadeOut(300).eq(i).fadeIn(500);
                 });
            }
            gonext();//下一步

      $('.c46').click(function()
            {
                index=1;
                 $('.processorBox li').removeClass('current').eq(index).addClass('current');
                        $('.step').fadeOut(300).eq(index).fadeIn(500);

            })
            $('.secondstep').click(function()
            {
                index=2;
                $('.processorBox li').removeClass('current').eq(index).addClass('current');
                        $('.step').fadeOut(300).eq(index).fadeIn(500);
            })
}